package edu.yuhf.stringdemo;

import java.util.Arrays;
import java.util.List;
import java.util.function.BinaryOperator;

public class MyString {

    public void subString(){
        String email = " thelongestday.yuhf@gmail.com ";
        String user = email.trim().substring(0,email.trim().indexOf("@"));
        System.out.println(user);
    }
    public boolean checkJavaFile(String fileName){
        if(null!=fileName&&fileName.indexOf(".")!=-1){
            String extName = fileName.substring(fileName.indexOf(".")+1);
            if(extName.toLowerCase().equals("java")){
                return true;
            }
        }else{
            System.out.println("文件不存在或文件格式错误");
        }
        return false;
    }
    public void splits(){
        String value="长亭外，古道边，芳草碧连天";
        String[] arrays = value.split("，");
        Arrays.stream(arrays).forEach(System.out::print);
        List<String> list = Arrays.asList(arrays);
        String newValue = String.join(":",list);
        System.out.println();
        System.out.println(newValue);
    }

    public void stringIntern(){
        String str0 = new String("hello world!");   //不查询StringTable,也不往Stringtable中放，当成一般对象使用
        String str1 = str0.intern();
        String str2 = "hello world!";
        System.out.println(str2==str1);

    }
}
